/**
 * 
 */
package IndexComponent;

import RecordManagement.RID;

/**
 * @author Neil
 *
 */
public class IX_IndexHandle implements IX_IndexHandle_Interface {

	boolean open;
	BPlusTree bptree;
	

	public IX_IndexHandle(BPlusTree bptree) {
		this.bptree = bptree;
		open = true;
	}

	/* (non-Javadoc)
	 * @see IndexComponent.IX_IndexHandle_Interface#DeleteEntry(byte[], RecordManagement.RID)
	 */
	@Override
	public void DeleteEntry(Keyword key, RID rid) {
		if (!open)
			throw new IX_Abort_Exception("Handle Not Open");
		bptree.DeleteEntry(key, rid);
	}

	/* (non-Javadoc)
	 * @see IndexComponent.IX_IndexHandle_Interface#ForcePages()
	 */
	@Override
	public void ForcePages() {
		bptree.pfh.ForcePages();
	}

	/* (non-Javadoc)
	 * @see IndexComponent.IX_IndexHandle_Interface#InsertEntry(byte[], RecordManagement.RID)
	 */
	@Override
	public void InsertEntry(Keyword key, RID rid) {
		if (!open)
			throw new IX_Abort_Exception("Handle Not Open");
		bptree.InsertEntry(key, rid);
	}

	@Override
	public IX_IndexScan OpenScan(int compOp, Keyword compValue) {
		if (!open)
			throw new IX_Abort_Exception("Handle Not Open");
		return bptree.OpenScan(compValue, compOp);
	}

}
